/**
 * Copyright (c) 2007,中企动力华南研发中心<br>
 * All rights reserved.
 */
package com.ce.pms.renovation.service.impl;

import java.math.BigDecimal;
import java.util.Date;

import org.dbunit.operation.DatabaseOperation;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.ce.pms.DBUnitTool;
import com.ce.pms.renovation.service.IRenovateManageService;
import com.ce.pms.renovation.vo.RenovateRequisitionQueryVO;
import com.ce.pms.renovation.vo.RenovateRequisitionVO;
import com.ce.util.BeanUtil;
import com.sitechasia.webx.core.support.Page;


/**
 * 功能描述：<br>
 * @author 罗军林 创建日期：2008-12-22
 */
public class RenovateManageServiceImplT extends DBUnitTool
{
	private IRenovateManageService renovateManageService;

	@Before
	public void setUp() throws Exception{
		super.setUp();
		renovateManageService=(IRenovateManageService)applicationContext.getBean("renovateManageService");
	}

	@Override
	protected DatabaseOperation setUpOp() {
		return DatabaseOperation.INSERT;
	}

	@Override
	protected DatabaseOperation tearDownOp() {
		return DatabaseOperation.DELETE;
	}

	@Override
	protected String[] getDataSetFilePaths() {
		StringBuilder sb
		   = new StringBuilder("xmlset").append("/").append("luojunlin").append("/");
		String dirStr = sb.toString();
		return new String[]{dirStr+"renovate_requisition.xml"};
	}

	@Test
	public void testQueryRequisitions(){
		RenovateRequisitionQueryVO queryCondition=new RenovateRequisitionQueryVO();
		queryCondition.setPageNo(1);
		queryCondition.setPageSize(15);
		Page page=renovateManageService.queryRequisitions(queryCondition);
		Assert.assertTrue(page.getResult().size()==3);
	}

	@Test
	public void testAddRequisition(){
		RenovateRequisitionVO renovateRequisitionVO=new RenovateRequisitionVO();
		renovateRequisitionVO.setHouseNumber("1-2A");
		renovateRequisitionVO.setClientNames("测试");
		renovateRequisitionVO.setArea(new BigDecimal("100"));
		renovateRequisitionVO.setLinkman("张三");
		renovateRequisitionVO.setLinkManPhone("139000000");
		renovateRequisitionVO.setRenovateType("001");
		renovateRequisitionVO.setBurdenMan("负责人");
		renovateRequisitionVO.setBurdenManPhone("12333333");
		renovateRequisitionVO.setItems("dfasdf");
		renovateRequisitionVO.setIdentityCard("3622011234566");
		renovateRequisitionVO.setFireproofingMan("KKK");
		renovateRequisitionVO.setRequisitionDate(new Date());
		renovateRequisitionVO.setBeginDate(new Date());
		renovateRequisitionVO.setEndDate(new Date(2009,1,1));
		renovateRequisitionVO.setCreator(1l);

		RenovateRequisitionVO result=renovateManageService.addRequisition(renovateRequisitionVO);
		Assert.assertNotNull("增加申请失败", result);
		BeanUtil.printfInfo(result, true);
		Assert.assertNotNull("申请单号没有生成", result.getRequisitionNumber());

		renovateManageService.deleteRequisition(result.getKeyword());

	}
}
